package com.example.contestsystem.Service;

import com.example.contestsystem.Dao.ContestFileRepository;
import com.example.contestsystem.Entity.FileEntity;
import org.springframework.stereotype.Service;

@Service
public class FileService {
    final ContestFileRepository contestFileRepository;

    public FileService(ContestFileRepository contestFileRepository){
        this.contestFileRepository = contestFileRepository;
    }

    public boolean upload(FileEntity fileEntity){
        this.contestFileRepository.save(fileEntity);
        return this.contestFileRepository.findByContestIdAndFileId(fileEntity.getContestId(), fileEntity.getFileId()) != null;
    }


}
